import jieba
from collections import Counter
from wordcloud import WordCloud
import matplotlib.pyplot as plt
with open('E:\GGB\西游记.txt', 'r', encoding='utf-8') as f:
    text = f.read()
word_list = jieba.cut(text, cut_all=False)
words = ' '.join(word_list)
word_counts = Counter(words.split())
word_counts = {word: count for word, count in word_counts.items() if count > 5}
wordcloud = WordCloud(font_path='simhei.ttf', background_color='white').generate_from_frequencies(word_counts)
plt.figure(figsize=(10, 10))
plt.imshow(wordcloud, interpolation='bilinear')
plt.axis("off")
plt.show()